package oj;

import java.util.LinkedList;
import java.util.List;
import java.util.Stack;

public class Num94 {
    List<Integer> ret=new LinkedList<>();
    public List<Integer> inorderTraversal(TreeNode root) {
        if (root == null) {
            return ret;
        }
        Stack<TreeNode> stack=new Stack<>();
        TreeNode cur=new TreeNode();
        cur=root;
        while (cur!=null || !stack.isEmpty()){
            while (cur!=null) {
                stack.push(cur);
                cur=cur.left;
            }
            TreeNode node = stack.pop();
            ret.add(node.val);
            cur = node.right;
        }
        return ret;
    }
}
